﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.YiXiong.XML;

namespace Test
{
    public class xmltest
    {
        static void Main2(string[] args)
        {

            string file = System.IO.Directory.GetCurrentDirectory();
            Console.WriteLine(file);
            XmlAttributeCollection ac = new XmlAttributeCollection();
            ac.Add(new XmlAttribute("Name","ASP.NET"));
            ac.Add(new XmlAttribute("URL","http://www.qy.com.cn"));


           XMLHelper xml=new XMLHelper(@"c:\xml.xml");
         
           /**
            * 获得子节点的文本
            */
           string[] vs = xml.GetChildNodesInnerText("WebSites/WebSite/Task[@Name='ASP.NET']");
           foreach (string s in vs)
           {
               Console.WriteLine(s);
           }

          /**
           *子节点是否存在* 
           */
           bool b = xml.ExistNode("WebSites/WebSite[@Name='ASP.NET']/Task[@Name='ASP.NET']");
          Console.WriteLine(string.Format("节点存在:{0}",b));
            /**
             * 多个条件查询
             */
          b = xml.ExistNode("WebSites/WebSite[@Name='ASP.NET1']/Task[@Name='ASP.NET1']");
          Console.WriteLine(string.Format("节点存在:{0}", b));



          XmlAttributeCollection accs=  xml.GetNodeAttributes("WebSites/WebSite/Task[@Name='ASP.NET']");
          foreach (XmlAttribute a in accs)
          {
              Console.WriteLine(string.Format("name:{0},value:{1}", a.Name, a.Value));
          }



          /**
           * 
           */


         //  xml.CreateRootNode("WebSites");
            /*
             * 添加指定父节点
             * 
             */
         //  xml.AddNode("WebSites", "WebSite", string.Empty, ac);
           /*
            * 在指定属性值(Attribute)的节点添加元素
            */
       //    xml.AddElement("WebSites/WebSite[@Name='ASP.NET']", "Task", "Get", ac);
      //     xml.Save();


           Console.Read();
        }
    }
}
